# -*- coding: utf-8 -*-
# @Time : 2021/9/10 13:38
# @Author : 阿怪
# @Email : scg@gmail.com
# @File : CRM-ST-ZNX-15.py
# @Project : crm自动化测试项目实战
'''验证站内信的查看功能'''

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Chrome()
cookie = {'name': 'PHPSESSID', 'value': '0onrpth7nsd6mbi1hfgi99o2b1'}  # 获取到cookid
driver.get('http://192.168.1.140/')  # 访问服务器
driver.add_cookie(cookie)
driver.get('http://192.168.1.140/crm3/index.php?m=message')
#进入站内信首页


#1.点击写信进入编辑界面
add_send_locator = (By.ID,'send')
driver.find_element(*add_send_locator).click()
sleep(3)

#2.输入信息啥的
text_locator = (By.NAME,'content')   #内容输入框定位器
submit_locator = (By.NAME,'submit')    #发送按钮定位器

driver.find_element(By.CSS_SELECTOR,'#ta1 > input').click()    #收信人点击全选
driver.find_element(*text_locator).send_keys('我是测试')
driver.find_element(*submit_locator).click()

#3.去点击刚刚添加的这条信息,进行查看
driver.find_element(By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > a').click()
text = driver.find_element(By.CSS_SELECTOR,'body > div.container > div.row > div > div > table > tbody > tr:nth-child(3) > td:nth-child(2) > pre').text
print(text)
#text内容与发送内容一直即通过

sleep(3)
driver.quit()